package com.pan.behavioral.chain.node;


/**
 * shape 不纯的责任链模式
 * score 纯责任链模式
 * @param <T>
 */
public abstract class ChainNode<T> {

    protected ChainNode nextNode;

    public ChainNode(ChainNode nextNode){
        this.nextNode = nextNode;
    }


    public void response(T obj){
        if (isProcessable(obj)){
            handle(obj);
        }else {
            nextNode.response(obj);
        }
    }

    public abstract boolean isProcessable(T obj);

    public abstract void handle(T obj);

}
